Event.INFINITE = -1;

function Action(total) {
	this.remaining = total;
}

Action.prototype.apply = function(world) {
};

function ChangeDroidTypeAction(total, droidType) {
	Action.call(this, total);
	this.droidType = droidType;
};

ChangeDroidTypeAction.prototype = extend(Action);

ChangeDroidTypeAction.prototype.apply = function(world) {
	if (this.remaining == 0)
		return;
	var droid = world.getSelectedDroid();
	if (droid) {
		if (droid.changeDroidType(this.droidType)) {
			this.remaining -= 1;
		}
	}
};


function DroidBuffAction(total, buff, timeout) {
	Action.call(this, total);
	this.buff = buff;
	this.timeout = timeout || 0;
};

DroidBuffAction.prototype = extend(Action);

DroidBuffAction.prototype.apply = function(world) {
	if (this.remaining == 0)
		return;
	var droid = world.getSelectedDroid();
	if (droid) {
		if (droid.addBuff(new DroidBuff(this.buff, this.timeout))) {
			this.remaining -= 1;
		}
	}
};